<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
  <title id="au20941">ALTER RESOURCE GROUP</title>
  <body>
    <p id="sql_command_desc">Changes the limits of a resource group.</p>
    <section id="section2">
      <title>Synopsis</title>
      <codeblock id="sql_command_synopsis">ALTER RESOURCE GROUP <varname>name</varname> SET <varname>group_attribute</varname> <varname>value</varname></codeblock>
<p>where <varname>group_attribute</varname> is one of:</p>
      <codeblock>CONCURRENCY <varname>integer</varname>
CPU_RATE_LIMIT <varname>integer</varname> 
CPUSET <varname>tuple</varname> 
MEMORY_LIMIT <varname>integer</varname>
MEMORY_SHARED_QUOTA <varname>integer</varname>
MEMORY_SPILL_RATIO <varname>integer</varname></codeblock>
    </section>
    <section id="section3">
      <title>Description</title>
      <p><codeph>ALTER RESOURCE GROUP</codeph> changes the limits of a resource group. 
        Only a superuser can alter a resource group.</p>
        <p>You can set or reset the concurrency limit of a resource group that you create for roles to control the maximum
        number of active concurrent statements in that group. You can also reset the memory or CPU
        resources of a resource group to control the amount of memory or CPU resources that all
        queries submitted through the group can consume on each segment host.</p>
        <p>When you alter the CPU resource management mode or limit of a resource group, the new mode or limit is immediately applied.</p>
        <p>When you alter a memory limit of a resource group that you create for roles, the new resource limit is immediately applied if current resource usage is less than or equal to the new value and there are no running transactions in the resource group. If the current resource usage exceeds the new memory limit value, or if there are running transactions in other resource groups that hold some of the resource, then Greenplum Database defers assigning the new limit until resource usage falls within the range of the new value.</p>
        <p>When you increase the memory limit of a resource group that you create for external components, the new resource limit is phased in as system memory resources become available. If you decrease the memory limit of a resource group that you create for external components, the behavior is component-specific. For example, if you decrease the memory limit of a resource group that you create for a PL/Container runtime, queries in a running container may fail with an out of memory error.</p>
        <p>You can alter one limit type in a single <codeph>ALTER RESOURCE GROUP</codeph> call.</p>
    </section>
    <section id="section4">
      <title>Parameters</title>
      <parml>
        <plentry>
          <pt><varname>name</varname></pt>
          <pd>The name of the resource group to alter. </pd>
        </plentry>
        <plentry>
          <pt>CONCURRENCY <varname>integer</varname></pt>
          <pd>The maximum number of concurrent transactions, including active and idle transactions, that are permitted for resource groups that you assign to roles.
            Any transactions submitted after the <codeph>CONCURRENCY</codeph> value limit is
            reached are queued. When a running transaction completes, the earliest queued
            transaction is run.</pd>
          <pd> The <codeph>CONCURRENCY</codeph> value
            must be an integer in the range [0 .. <codeph>max_connections</codeph>]. The default 
            <codeph>CONCURRENCY</codeph> value for a resource group that you create for roles is 20.</pd>
            <pd><note>You cannot set the <codeph>CONCURRENCY</codeph> value for the <codeph>admin_group</codeph> to zero (0).</note></pd>
        </plentry>
        <plentry>
          <pt>CPU_RATE_LIMIT <varname>integer</varname></pt>
          <pd>The percentage of CPU resources to allocate to
            this resource group. The minimum CPU percentage for a resource group is 1.
            The maximum is 100. The sum of the
            <codeph>CPU_RATE_LIMIT</codeph>s of all resource groups defined in the
            Greenplum Database cluster must not exceed 100.</pd>
          <pd>If you alter the <codeph>CPU_RATE_LIMIT</codeph> of a resource group in which
            you previously configured a <codeph>CPUSET</codeph>, <codeph>CPUSET</codeph> is disabled, the reserved CPU cores are returned to Greenplum Database, and <codeph>CPUSET</codeph> is set to -1.</pd>
        </plentry>
        <plentry>
          <pt>CPUSET <varname>tuple</varname></pt>
          <pd>The CPU cores to reserve for this resource group. The CPU cores that you specify in <varname>tuple</varname> must be available in the system and cannot overlap with any CPU cores that you specify for other resource groups.</pd>
          <pd><varname>tuple</varname> is a comma-separated list of single core numbers or core intervals. You must enclose <varname>tuple</varname> in single quotes, for example, '1,3-4'.</pd>
          <pd>If you alter the <codeph>CPUSET</codeph> value of a resource group for which
            you previously configured a <codeph>CPU_RATE_LIMIT</codeph>, <codeph>CPU_RATE_LIMIT</codeph> is disabled, the reserved CPU resources are returned to Greenplum Database, and <codeph>CPU_RATE_LIMIT</codeph> is set to -1.</pd>
          <pd>You can alter <codeph>CPUSET</codeph> for a resource group only after you have enabled resource group-based resource management for your Greenplum Database cluster.</pd>
        </plentry>
        <plentry>
          <pt>MEMORY_LIMIT <varname>integer</varname></pt>
          <pd>The percentage of Greenplum Database memory resources to reserve for 
            this resource group. The minimum memory percentage for a resource group is 0.
            The maximum is 100. The default value is 0.</pd>
          <pd>When <codeph>MEMORY_LIMIT</codeph> is 0, Greenplum Database reserves no
            memory for the resource group, but uses global shared memory to fulfill all
            memory requests in the group. If <codeph>MEMORY_LIMIT</codeph> is 0,
            <codeph>MEMORY_SPILL_RATIO</codeph> must also be 0.</pd>
          <pd>The sum of the
            <codeph>MEMORY_LIMIT</codeph>s of all resource groups defined in the
            Greenplum Database cluster must not exceed 100. If this sum is less
            than 100, Greenplum Database allocates any unreserved memory to a resource
            group global shared memory pool.</pd>
        </plentry>
        <plentry>
          <pt>MEMORY_SHARED_QUOTA <varname>integer</varname></pt>
          <pd>The percentage of memory resources to share among transactions in
            the resource group. The minimum memory shared quota percentage for a
            resource group is 0. The maximum is 100. The default
            <codeph>MEMORY_SHARED_QUOTA</codeph> value is 80.</pd>
        </plentry>
        <plentry>
          <pt>MEMORY_SPILL_RATIO <varname>integer</varname></pt>
          <pd>The memory usage threshold for memory-intensive operators in a transaction.
            You can specify an integer percentage value from 0 to 100 inclusive. The default
            <codeph>MEMORY_SPILL_RATIO</codeph> value is 0. When <codeph>MEMORY_SPILL_RATIO</codeph>
            is 0, Greenplum Database uses the
            <xref href="../config_params/guc-list.xml#statement_mem" format="dita"><codeph>statement_mem</codeph></xref>
            server configuration parameter value to control initial query operator memory.</pd>
        </plentry>
      </parml>
    </section>
    <section id="section5">
      <title>Notes</title>
      <p>Use <codeph><xref href="./CREATE_ROLE.xml#topic1" type="topic" format="dita"/></codeph> or
            <codeph><xref href="./ALTER_ROLE.xml#topic1" type="topic" format="dita"/></codeph> to
        assign a specific resource group to a role (user).</p>
      <p>You cannot submit an <codeph>ALTER RESOURCE GROUP</codeph> command in an explicit transaction or sub-transaction.</p>
    </section>
    <section id="section6">
      <title>Examples</title>
      <p>Change the active transaction limit for a resource group: </p>
      <codeblock>ALTER RESOURCE GROUP rgroup1 SET CONCURRENCY 13;</codeblock>
      <p>Update the CPU limit for a resource group: </p>
      <codeblock>ALTER RESOURCE GROUP rgroup2 SET CPU_RATE_LIMIT 45;</codeblock>
      <p>Update the memory limit for a resource group: </p>
      <codeblock>ALTER RESOURCE GROUP rgroup3 SET MEMORY_LIMIT 30;</codeblock>
      <p>Update the memory spill ratio for a resource group: </p>
      <codeblock>ALTER RESOURCE GROUP rgroup4 SET MEMORY_SPILL_RATIO 25;</codeblock>
      <p>Reserve CPU core 1 for a resource group: </p>
      <codeblock>ALTER RESOURCE GROUP rgroup5 SET CPUSET '1';</codeblock>
    </section>
    <section id="section7">
      <title>Compatibility</title>
      <p>The <codeph>ALTER RESOURCE GROUP</codeph> statement is a Greenplum Database extension. This
        command does not exist in standard PostgreSQL.</p>
    </section>
    <section id="section8">
      <title>See Also</title>
      <p><codeph><xref href="./CREATE_RESOURCE_GROUP.xml#topic1" type="topic" format="dita"
          /></codeph>, <codeph><xref href="./DROP_RESOURCE_GROUP.xml#topic1" type="topic"
            format="dita"/></codeph>, <codeph><xref href="./CREATE_ROLE.xml#topic1" type="topic"
            format="dita"/></codeph>, <codeph><xref href="./ALTER_ROLE.xml#topic1" type="topic"
            format="dita"/></codeph></p>
    </section>
  </body>
</topic>
